<?php

class commentComponents extends sfComponents
{
  public function executeForm(sfWebRequest $request)
  {
    $comment = new BlogComment();
    $comment->setPost($this->post);

    $this->form = new BlogCommentForm($comment, array(
      'env' => sfConfig::get('sf_environment'),
      'recaptcha_public_key' => sfConfig::get('app_recaptcha_public_key'), 
      'recaptcha_private_key' => sfConfig::get('app_recaptcha_private_key'), 
    ));

    if ($request->isMethod('post'))
    {
      $this->form->bind($request->getParameter($this->form->getName()));
    }
  }
  
  public function executeLastComments(sfWebRequest $request)
  {
    $this->comments = Doctrine_Core::getTable('BlogComment')->retrieveLastActiveComments(
      $this->getUser()->getCulture(),
      sfConfig::get('app_comments_max_in_sidebar', 10)
    );
  }
}